#ifndef __BUOLA_WIDGETS_CHANDLEBAR_H__
#define __BUOLA_WIDGETS_CHANDLEBAR_H__

#include <buola/widgets/cwidget.h>
#include <buola/utility/uevent.h>
#include <buola/widgets/ctheme.h>

namespace buola { namespace gui {

class CHandleBar : public CWidget
{
public:
    enum
    {
        //renderers
        STYLE_WHOLEBAR=        0x00000100,
        STYLE_CLOSEBUTTON=     0x00000200
    };
    
    CHandleBar();
    ~CHandleBar();

    void SetCaption(const std::wstring &pCaption);
    
protected:
    CTheme::EDecoFlags GetArea(const CPoint_d &pP);

////////////// Event handling //////////////
    virtual void OnSize(const CGeometryEvent &pE);
    virtual void OnExpose(const CExposeEvent &pE);
    virtual void OnButtonDown(const CMouseEvent &pE);
    virtual void OnButtonUp(const CMouseEvent &pE);
    virtual void OnMouseMove(const CMouseEvent &pE);
    virtual void OnMouseOut(const CMouseEvent &pE);

public:
    UEvent<void()> eClose;
    UEvent<void()> eDock;

    USignal<void(const CPoint_d&)> sStartMove;
    USignal<void(const CPoint_d&)> sContinueMove;
    USignal<void()> sEndMove;
    
protected:
////////////////// data //////////////////
    std::wstring mCaption;

    bool mMoving;

    int mPressedArea;
    CTheme::EDecoFlags mOverArea;

////////////////// static data //////////////////
};

/*namespace gui*/ } /*namespace buola*/ }

#endif
